# encoding:UTF-8
import pymysql,re,time,requests,urllib.request
from collections import OrderedDict

url='http://www.newrank.cn/xdnphb/list/day/rank'
headers = {
    'Accept':'application/json,text/javascript,*/*;q=0.01',
    'Accept-Encoding':'gzip,deflate',
    'Accept-Language':'zh-CN,zh;q=0.8',
    'Connection':'keep-alive',
    'Content-Length':'148',
    'Content-Type':'application/x-www-form-urlencoded;charset=UTF-8',
    'Cookie':'UM_distinctid=15e74b07c1e83e-088bd881534ffd-59462f1d-1fa400-15e74b07c1f679;__root_domain_v=.newrank.cn;_qddamta_2852150610=3-0;CNZZDATA1253878005=722433827-1505195880-null%7C1507878243;Hm_lvt_a19fd7224d30e3c8a6558dcb38c4beed=1505383007,1507865964;Hm_lpvt_a19fd7224d30e3c8a6558dcb38c4beed=1507883413;_qddaz=QD.vfnr5e.jae01q.j7h7012c;_qdda=3-1.3ltmxb;_qddab=3-8fpy9t.j8pm681a',
    'Host':'www.newrank.cn',
    'Origin':'http://www.newrank.cn',
    'Referer':'http://www.newrank.cn/public/info/list.html?period=day&type=data',
    'User-Agent':'Mozilla/5.0(WindowsNT10.0;WOW64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/60.0.3112.90Safari/537.36',
    'X-Requested-With':'XMLHttpRequest'
    }
data={"end":"2017-10-12","rank_name":"时事","rank_name_group":"资讯","start":"2017-10-12","nonce":"f9d18b087","xyz":"bc5a7b6dc76bf4357299fdc6ed260021"}
proxies = { "http": "http://122.193.14.102:80", "https": "https://180.97.235.30:80"}
r = requests.post(url = url,headers = headers, data=data)  #32-33行 爬时间排序评论
print(r.json())
# 微博：http://www.newrank.cn/xdnphb/list/weibo_day/rank
# 微信：http://www.newrank.cn/xdnphb/list/day/rank
# comment_page = r.json()['data']
# if r.status_code ==200:
#     try:
#         print(comment_page)
#         time.sleep(3)
#     except:
#         print("error")